/**
 * 
 */
package com.dsteiner.widgets.client.model;

import java.beans.PropertyChangeListener;

import com.dsteiner.widgets.client.PropertyChangeCollection;

public class PrefilledTextBoxModel {
	protected PropertyChangeCollection propertyChangeSupport = new PropertyChangeCollection(
			this);

	private int keyCode;

	private boolean hasFocus;

	private String text;

	private String defaultText;
	private boolean edited;

	public void addPropertyChangeListener(String propertyName,
			PropertyChangeListener listener) {
		propertyChangeSupport.registerPropertyChangeListener(propertyName,
				listener);
	}

	private boolean hasError;

	public boolean hasError() {
		return hasError;
	}

	public void setHasError(boolean hasError) {
		boolean oldhasError = this.hasError;
		this.hasError = hasError;
		propertyChangeSupport.firePropertyChange("hasError", oldhasError, hasError);
	}
	private Integer maxCount;

	public Integer getMaxCount() {
		return maxCount;
	}

	public void setMaxCount(Integer maxCount) {
		Integer oldMaxCount = this.maxCount;
		this.maxCount = maxCount;
		propertyChangeSupport.firePropertyChange("maxCount", oldMaxCount, maxCount);
	}
	public String getDefaultText() {
		return defaultText;
	}
	public int getKeyCode() {
		return keyCode;
	}

	public String getText() {
		return text;
	}

	public boolean hasFocus() {
		return hasFocus;
	}
	public boolean isEdited() {
		return edited;
	}

	public void setDefaultText(String defaultText) {
		String oldDefaultText = this.defaultText;
		this.defaultText = defaultText;
		propertyChangeSupport.firePropertyChange("defaultText", oldDefaultText, defaultText);
	}

	public void setEdited(boolean edited) {
		boolean oldEdited = this.edited;
		this.edited = edited;
		propertyChangeSupport.firePropertyChange("edited", oldEdited, edited);
	}
	
	public void setHasFocus(boolean hasFocus) {
		boolean oldHasFocus = this.hasFocus;
		this.hasFocus = hasFocus;
		propertyChangeSupport.firePropertyChange("hasFocus", oldHasFocus, hasFocus);
	}

	public void setKeyCode(int keyCode) {
		int oldKeyCode = this.keyCode;
		this.keyCode = keyCode;
		propertyChangeSupport.firePropertyChange("keyCode", oldKeyCode, keyCode);
	}

	public void setText(String text) {
		String oldText = this.text;
		this.text = text;
		propertyChangeSupport.firePropertyChange("text", oldText, text);
	}

}